#include "widget.h"
#include "ui_widget.h"
#include<fstream>
#include<QDebug>
#include<QDir>
#include<QFile>
#include<QTextStream>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QFile file(":/1.txt");
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        {
            qDebug() << "无法打开文件：";
            return;
        }
   //  qDebug() << "当前工作目录:" << QDir::currentPath();

  //  std::string tmp;
    QTextStream in(&file);
    in.setCodec("UTF-8");
    while(!in.atEnd())
    {
        ui->comboBox->addItem(in.readLine());
    }
    file.close();
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    const QString& tmp = ui->comboBox->currentText();
    ui->label->setText(tmp);
}
